<template>
    <div class="stepBox">
        <div class="cont">
            <basic-form
                :showAlert="false"
                message="请先填写基本信息提交保存后，再上传证照扫描图片"
                :isBtn="false"
                :formInfos="s_FormInfo"
                :formDatas="s_formDatas"
                :rules="s_rules"
                ref="forms"
                @onSubmit="onSubmit"
                @onChangeType="onChangeType"
            ></basic-form>
        </div>
        <div class="btnBox">
            <a-button class="btn"  type="primary"  @click="nexts()">
                下一步
            </a-button>
        </div>
    </div>
</template>

<script>
import basicForm from '../common/basicForm'
import {saveInfo } from './saleDelivery'
const s_FormInfo = [
  { label: '销售单号', name: 'saleOrderNo', type: 'input',isDisabled:true, placeholder: '请输入销售单号' },
  { label: '配送单号', name: 'deliveryOrderNo', type: 'input',  placeholder: '请选择配送单号' },
  { label: '配送单名称', name: 'deliveryOrderName', type: 'input',  placeholder: '请选择配送单名称' },
  // { label: '是否关联多个订单', name: 'multipleOrder', type: 'input', placeholder: '是否关联多个订单' },
  // { label: '关联订单', name: 'associatedOrder', type: 'input', placeholder: '关联订单' },
  // { label: '物流关联单号', name: 'logisticsNo', type: 'input', placeholder: '请输入物流关联单号' },
  { label: '送货类型', name: 'deliveryType', type: 'dicselect',dicName: 'deliveryType',  placeholder: '请选择送货类型' },
  { label: '寄件人姓名', name: 'sender', type: 'input', placeholder: '请输入寄件人姓名' },
  { label: '寄件人联系电话', name: 'senderTel', type: 'input', placeholder: '请输入寄件人联系电话' },
  { label: '寄件人证件类型', name: 'senderCertificateType', type: 'input', placeholder: '请输入寄件人证件类型' },
  { label: '寄件人证件号码', name: 'senderCertificateNo', type: 'input', placeholder: '请输入寄件人证件号码' },
  { label: '收件人姓名', name: 'receiver', type: 'input', placeholder: '请输入收件人姓名' },
  { label: '收件人联系电话', name: 'receiverTel', type: 'input', placeholder: '请输入收件人联系电话' },
  { label: '收件地址', name: 'receiverAddr', type: 'input', placeholder: '请输入收件地址' },
  { label: '物流方', name: 'logistics', type: 'input', placeholder: '请输入物流方' },
  { label: ['保存', '重置'], type: 'botton' },
]

const s_formDatas = {
  sysSeq: 0,
  pid: null,
  saleOrderNo: null,
  deliveryOrderNo: null,
  deliveryOrderName: null,
  multipleOrder: null,
  associatedOrder: null,
  deliveryType: null,
  sender: null,
  senderTel: null,
  senderCertificateType: null,
  senderCertificateNo: null,
  receiver: null,
  receiverTel: null,
  receiverAddr: null,
  logisticsNo: null,
  logistics: null,
  deliveryState:'待配送'
}
const s_rules = {
  sender: [{ required: true, message: '寄件人姓名必填', trigger: 'blur' }],
  senderTel: [{ required: true, message: '寄件人联系电话必填', trigger: 'blur' }],
  receiver: [{ required: true, message: '收件人姓名必填', trigger: 'blur' }],
  receiverTel: [{ required: true, message: '寄件人联系电话必填', trigger: 'blur' }],
  receiverAddr: [{ required: true, message: '收件地址必填', trigger: 'blur' }],
}
export default {
  props: {
    orRrecord:{
      type:Object,
    }
  },
  components: {
    basicForm,
  },
  data() {
    return {
     s_FormInfo:s_FormInfo,
      s_formDatas: s_formDatas,
      s_rules: s_rules,
      isSubmit:false
    }
  },
  created(){

  },
  mounted() {
    console.log("000000000");
    this.s_formDatas.saleOrderNo=this.orRrecord.saleOrderNo
    this.s_formDatas.deliveryType=this.orRrecord.deliveryType
  },
  methods: {
    nexts(){
        this.$refs.forms.submitForm()
    },
    onSubmit(val) {
      if(this.isSubmit){
          this.$emit('nextStep')
      }else{
        this.saveObjInfo(val)
      }
      
    },
    // 保存详细信息
    async saveObjInfo(val) {
      // this.$message.loading({ content: '提交中'， })
      let res = await saveInfo(val)
      console.log(res)
      if (res && res.code && res.code === 'C1' && res.data) {
        this.$message.success({ content: '保存成功', duration: 2 })
        this.isSubmit=true;
        this.$emit('nextStep',res.data)
      } else {
        this.$message.error({ content: '保存失败', duration: 2 })
      }
    },
        // 表单编号
    onChangeType(name, val) {
      const _this = this
      switch (name) {
        case 'xiaoShoucpPid':
          _this.getSaleGoodsInfo(val)
          break
        case 'keHuPid':
          _this.getCustomerInfo(val)
          break
        case 'zhongBiaolx':
          _this.s_formDatas.zhongBiaolx = val
          break
        case 'laiYuanlx':
          _this.s_formDatas.laiYuanlx = val
          break
      }
    },
  },
}
</script>

<style scoped>
.stepBox{
    width: 100%;
    height: 100%;
    position: relative;
}
.cont{
  padding-left: 5px;
  max-height:calc( 70vh - 40px );
  overflow-y: scroll;
}
.btnBox{
  height: 7vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items:flex-end;
  /* border: 1px solid #eee; */
  position: absolute;
  bottom: 0px;
}

</style>


